home *** CD-ROM | disk | FTP | other *** search
/ Light ROM 1 / LIGHT-ROM 1 (Amiga Library Services)(1994).iso / ffdisks / d949.lha / BBBBS / BBBBS65.lha / rexx / SendFile.rexx < prev    next >
OS/2 REXX Batch file  |  1993-09-16  |  8KB  |  268 lines

  1. /* SendFile.rexx by Matt English & John Ruckart 9-20-92  version 1.2
  2.    alterations by Richard Lee Stockton, 2 Aug 93 version 1.2a
  3.                                        16 Sep 93 version 1.2b
  4.    This is a utility for BBBBS sysops.
  5.    This will allow you to send emailfiles to any BBS user quickly and
  6.    without having to load-up BBSlocal. You can even send emailfiles to
  7.    someone who is on line at the time. Very easy to use.
  8.    This is freely distributable as long as no-one makes any money on
  9.    it, this notice remains, and the credits at the main menu remain.
  10.    If you find a bug, or have an idea for additional features, please give
  11.    me a call at The Alternative BBS, 503-761-3043. Matt English.
  12.  
  13. ******* Thanks to John Ruckart for help & bug testing! ************/
  14.  
  15. IF ~SHOW('P','QuickSortPort') THEN CALL setup.rexx()
  16. IF ~SHOW('P','QuickSortPort') THEN EXIT 666
  17.  
  18. figarg='s:CONFIG.BBS'
  19. IF ~EXISTS(figarg) THEN figarg='BBS:BBS_TEXT/CONFIG.BBS'
  20. x=OPEN(f,figarg,'R')
  21. IF x=0 THEN
  22.   DO
  23.     SAY 's:CONFIG.BBS and BBS:BBS/CONFIG.BBS are both missing!'
  24.     CALL GETOUT(21)
  25.   END
  26. lynes.=''
  27. DO i=1 TO 33
  28.   lynes.i=READLN(f)
  29. END
  30. CALL CLOSE(f)
  31. compos=POS('/*',lynes.1)
  32. IF compos>0 THEN lynes.1=LEFT(lynes.1,compos-1)
  33. bbsname=STRIP(lynes.1)
  34. sysopname=WORD(lynes.2,1)
  35. bbsdevice=word(lynes.4,1)
  36. bbspath=WORD(lynes.6,1)
  37. IF ~EXISTS(bbspath) THEN
  38.   DO
  39.     SAY bbspath 'does not exist!'
  40.     CALL SETCLIP('BBS_ALPHA')
  41.     CALL GETOUT(22)
  42.   END
  43. testchar=RIGHT(bbspath,1)
  44. IF testchar~='/' & testchar~=':' THEN bbspath=bbspath'/'
  45. cushion=word(lynes.12,1)
  46.  
  47. pen1 = ''
  48. pen2 = ''
  49. pen3 = ''
  50. def = ''
  51.  
  52. start:
  53.  
  54. say'   'pen3'                       SendFile  '
  55. say'              'pen3'      Version 1.2b  16 Sep 93'
  56. say'                     'pen2'  by Matt English 'def''
  57. say
  58. Options prompt' Who would you like to send a file to? 'pen3'(Q=Quit)'def' > '
  59.  pull sendname
  60.  sendname = strip(upper(sendname))
  61.  sendname = translate(sendname,'_',' ')
  62.  if sendname = '' then call start
  63.  if sendname = 'Q' then exit
  64.  say' Searching for 'pen3''sendname''def'...'
  65.  call open(names,bbspath'lists/users','r')
  66.  foundhim = 0
  67.  do until foundhim = 1
  68.   nameline = readln(names)
  69.   do i = 1 to 3
  70.    user = strip(word(nameline,i))
  71.    if user = '' then do
  72.     say
  73.     say' I can''t find 'pen3''sendname''def' on the BBS list!'
  74.     options prompt' Would you like to view the user list? (Y,n) > '
  75.     pull view
  76.     say
  77.     call seek(names,0,'b')
  78.     if view = 'N' then do
  79.      call close(names)
  80.      call start
  81.      end
  82.     stop = 0
  83.     j = 0
  84.     do until stop = 1
  85.      j = j + 1
  86.      sayline = strip(readln(names))
  87.      if sayline ~= '' then say' 'sayline''
  88.      if j // 16 = 0 | sayline = '' then do
  89.       say
  90.       options prompt' Return = continue      Q = Quit > '
  91.       pull cont
  92.       say
  93.       if cont = 'Q' then do
  94.        call close(names)
  95.        call start
  96.        end
  97.       end
  98.      if eof(names) then do
  99.       call close(names)
  100.       call start
  101.       end
  102.      end
  103.     end
  104.    if user = sendname then do
  105.     call close(names)
  106.     foundhim = 1
  107.     end
  108.    end
  109.   end
  110.   if foundhim = 0 then do
  111.     say
  112.     say' I can''t find 'pen3''sendname''def' on the BBS list!'
  113.     options prompt' Would you like to view the user list? (Y,n) > '
  114.     pull view
  115.     say
  116.     if view = 'N' then do
  117.      call close(names)
  118.      call start
  119.      end
  120.     call seek(names,0,'b')
  121.     stop = 0
  122.     j = 0
  123.     do until stop = 1
  124.      j = j + 1
  125.      sayline = strip(readln(names))
  126.      if sayline ~= '' then say' 'sayline''
  127.      if j // 16 = 0 | sayline = '' then do
  128.       say
  129.       options prompt' Return = continue      Q = Quit > '
  130.       pull cont
  131.       say
  132.       if cont = 'Q' then do
  133.        call close(names)
  134.        call start
  135.        end
  136.       end
  137.      if eof(names) then do
  138.       call close(names)
  139.       call start
  140.       end
  141.      end
  142.     end
  143.   say' 'sendname' has been located...'
  144.   say
  145.   say' Please select a file to send...'
  146.   say
  147.   frompath=GETCLIP('BBS_frompath')
  148.   fullfile=GetFile(150,36,frompath,'',' Select File to Send ')
  149.   IF fullfile='' THEN SIGNAL start
  150.   x=POS('/',fullfile)
  151.   IF x=0 THEN x=POS(':',fullfile)
  152.   IF x>0 THEN
  153.     DO
  154.       sendfile=SUBSTR(fullfile,x+1)
  155.       frompath=LEFT(fullfile,x)
  156.       IF RIGHT(frompath,1)='/' THEN frompath=LEFT(frompath,x-1)
  157.       CALL SETCLIP('BBS_frompath',frompath)
  158.     END
  159.   ELSE sendfile=fullfile
  160.   address command'c:info 'bbsdevice' > Ram:is_disk_in' /* Check to see if a disk is in df0: */
  161.   call open(disktest,'Ram:is_disk_in','r')
  162.   do 3
  163.    r = readln(disktest)
  164.    end
  165.   infoline = readln(disktest)
  166.   call close(disktest)
  167.   blocksfree = word(infoline,4)
  168.   bytesfree = (blocksfree * 512) - cushion
  169.   say' There are 'pen3''bytesfree''def' bytes available for UpLoading...'
  170.   say
  171.   if exists(fullfile) then address command'c:list 'fullfile' nohead > Ram:fileinfo' /* Check to see if a disk is in df0: */
  172.   else do
  173.    say' 'pen3'I can''t find that file... Hmmm....'
  174.    say' 'pen2'SENDFILE canceled..'
  175.    call delay(50)
  176.    call start
  177.    end
  178.   if RC > 10 then call start
  179.   call open(bytetest,'Ram:fileinfo','r')
  180.   infoline = readln(bytetest)
  181.   call close(bytetest)
  182.   bytes = word(infoline,2)
  183.   say' The file is 'bytes' bytes!'
  184.   if bytes > bytesfree then do
  185.    say
  186.    say' Sorry, there''s not enough room for that file on your BBS device!'
  187.    say' 'pen3'SENDFILE has been canceled!'def''
  188.    call delay(50)
  189.    say
  190.    end
  191.   say
  192.   /* Check to see if emailfile dir exists for this user */
  193.   emdirs = showdir(bbspath'emailfiles','d')
  194.   gotdir = 0
  195.   e = 0
  196.   do until gotdir = 1
  197.    e = e + 1
  198.    if sendname = word(emdirs,e) then gotdir = 1
  199.    if e = words(emdirs) & gotdir = 0 then do
  200.     makedir(bbspath'emailfiles/'sendname)
  201.     gotdir = 1
  202.     end
  203.    end
  204.   address command'c:copy 'fullfile' 'bbspath'emailfiles/'sendname''
  205.   checkit = showdir(bbspath'emailfiles/'sendname,'f')
  206.   itsok = ''
  207.   do c = 1 to words(checkit)
  208.    inthere = word(checkit,c)
  209.    if upper(inthere) = upper(sendfile) then itsok = 1
  210.    end
  211.   if itsok = '' then do
  212.    say
  213.    say' There was a problem with the file copy.. Email 'pen3'NOT'def' sent.'
  214.    call pressreturn
  215.    call start
  216.    end
  217.   call open(last,bbspath'Numbers/LastMail','r')
  218.   enum = readln(last) + 1
  219.   call close(last)
  220.   call open(last,bbspath'Numbers/LastMail','w')
  221.   call writeln(last,enum)
  222.   call close(last)
  223.   thedate = date()
  224.   thetime = time('c')
  225.   call open(note,bbspath'email/'sendname'/'sysopname'.'enum,'w')
  226.   call writeln(note,'Mail: 'enum' File: 'sendfile)
  227.   call writeln(note,'From: 'sysopname)
  228.   call writeln(note,'  To: 'sendname)
  229.   call writeln(note,'Subj: File Request')
  230.   call writeln(note,'Date: 'thedate'  'thetime)
  231.   call writeln(note,'====================================================================')
  232.   call writeln(note,' Here is the file that you requested!')
  233.   call writeln(note,'  - SysOp -')
  234.   call writeln(note,' ')
  235. /*  THE FOLLOWING CODE WAS ADDED TO ALLOW SYSOPS TO ADD TEXT TO MESSAGE */
  236.   options Prompt 'Do you wish to add to the message? (Ny) > '
  237.   pull answer
  238.   addone = 0
  239.   if answer = 'Y' then do
  240.     say' Hit return at the end of each line, blank line to end'
  241.      do until addone = 1
  242.       say
  243.       options Prompt '> '
  244.       parse pull line
  245.       if line ~='' then
  246.        call writeln(note,line)
  247.       else addone = 1
  248.      end
  249.     end
  250. /* END OF ADDED CODE */
  251.   call close(note)
  252.   say
  253.   say' The file has been sent, with a note attached!'
  254.   say
  255.   call alertuser
  256.   call delay(50)
  257.   call start
  258.  
  259. pressreturn:
  260. options prompt' 'pen3'Press return to continue'def''
  261. pull response
  262. say
  263. return
  264.  
  265. alertuser:
  266. If GETCLIP('BBS_level')~='' & WORD(GETCLIP('BBS_lastcaller'),1)=sendname THEN
  267. CALL SETCLIP('BBS_MESSAGE','You have a file in Email waiting for you.')
  268. RETURN